<template>
  <div id="login">
    <el-form ref="loginForm" :model="params">
      <el-form-item label="手机号">
        <el-input v-model="params.phone"></el-input>
      </el-form-item>
      <el-form-item label="验证码">
        <el-input v-model="params.code"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getCode">获取验证码</el-button>
        <el-button type="primary" @click="login">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

import { loginApi, getCodeApi } from '@/api/login/login'
import { showResponse } from '@/util/ResponseUtil'

export default {
  name: 'login',
  data () {
    return {
      params: {}
    }
  },
  methods: {
    async getCode () {
      let res = await getCodeApi(this.params)
      console.log(res)
      showResponse(res, '获取验证码失败')
    },
    async login () {
      let res = await loginApi(this.params)
      console.log(res)
      showResponse(res, '登录失败')
    }
  }
}
</script>

<style scoped>

</style>
